package chapter04.Example11;

interface Animal{
    int ID = 1;
    String NAME = "牧羊犬";
    void shout();
    static int getID(){
        return Animal.ID;
    }
    public void info();
}
interface Action{
    public void eat();
}
class Dog implements Animal,Action{
    public void eat(){
        System.out.println("喜欢吃骨头");
    }
    public void shout(){
        System.out.println("汪汪······");
    }
    public void  info(){
        System.out.println("名称:"+NAME);
    }
}
public class Example11 {
    public static void main(String[] args) {
        System.out.println("编号"+Animal.getID());
        Dog dog = new Dog();
        dog.info();
        dog.shout();
        dog.eat();
    }
}
 +29 第四章Example12.java  0 -> 100644
package chapter04.Example12;

interface Animal{
    public String NAME = "牧羊犬";
    public void shout();
    public void info();
}
abstract class Action{
    public abstract void eat();
}
class Dog extends Action implements Animal{
    public void eat() {
        System.out.println("喜欢吃骨头");
    }
    public void shout() {
        System.out.println("汪汪······");
    }
    public void info() {
        System.out.println("名称:"+NAME);
    }
}
public class Example12 {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.info();
        dog.shout();
        dog.eat();
    }
}
 +31 第四章Example13.java  0 -> 100644
package chapter04.Example13;

interface Animal{
    public String NAME = "牧羊犬";
    public void info();
}
interface Color{
    public void black();
}
interface Action extends  Animal,Color{
    public void shout();
}
class Dog implements Action{
    public void info() {
        System.out.println("名称:"+NAME);
    }
    public void black() {
        System.out.println("黑色");
    }
    public void shout() {
        System.out.println("汪汪······");
    }
}
public class Example13 {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.info();
        dog.shout();
        dog.black();
    }
}